package com.cxria.pattern.observer.func1;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public abstract class Subject {

    private List<Observer> observers;

    public Subject() {
        observers = Collections.synchronizedList(new ArrayList<>());
    }


    public void addOberver(Observer observer){
        observers.add(observer);
    }

    public void deleteOberver(Observer observer){
        observers.remove(observer);
    }

    public void notifyObservers(){
        for(Observer observer : observers){
            observer.update();
        }
    }

}
